﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class SignIn : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        Twitter twitter = new Twitter();       

        try
        {
            string sRet = twitter.Show(Login1.UserName, Login1.Password, Login1.UserName, Twitter.OutputFormatType.XML);

            TwitterUser user = new TwitterUser(Page);
            user.UserName = Login1.UserName;
            user.Password = Login1.Password;           

            try { LogLogin(Login1.UserName); }
            catch { }

            Response.Redirect("Default.aspx");
        }
        catch
        {

        }
                
    }

    private void LogLogin(string username)
    {
        LoginTableDataContext lt = new LoginTableDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["GeoTwitterDataConnectionString"].ConnectionString);
        SignTable item = new SignTable();
        item.username = username;
        item.timestamp = DateTime.Now;
        lt.SignTables.InsertOnSubmit(item);
        lt.SubmitChanges();
    }
}
